//
//  Macros.h
//  WeChat
//
//  Created by 黄柳姣 on 2018/4/29.
//  Copyright © 2018年 obally. All rights reserved.
//

#ifndef Macros_h
#define Macros_h
/// AppDelegate
#define OBSharedAppDelegate ((AppDelegate *)[UIApplication sharedApplication].delegate)

// 输出日志 (格式: [时间] [哪个方法] [哪行] [输出内容])
#ifdef DEBUG
#define NSLog(format, ...)  printf("\n[%s] %s [第%zd行] 💕 %s\n", __TIME__, __FUNCTION__, __LINE__, [[NSString stringWithFormat:format, ##__VA_ARGS__] UTF8String]);
#else

#define NSLog(format, ...)

#endif
// 打印方法
#define OBLogFunc NSLog(@"%s", __func__)
// 打印请求错误信息
#define OBLogError(error) NSLog(@"Error: %@", error)
// 销毁打印
#define OBDealloc NSLog(@"\n =========+++ %@  销毁了 +++======== \n",[self class])
// AppDelegate
#define OBSharedAppDelegate ((AppDelegate *)[UIApplication sharedApplication].delegate)
//  通知中心
#define OBNotificationCenter [NSNotificationCenter defaultCenter]

// 是否为空对象
#define OBObjectIsNil(__object)  ((nil == __object) || [__object isKindOfClass:[NSNull class]])

// 字符串为空
#define OBStringIsEmpty(__string) ((__string.length == 0) || OBObjectIsNil(__string))

// 字符串不为空
#define OBStringIsNotEmpty(__string)  (!OBStringIsEmpty(__string))

// 数组为空
#define OBArrayIsEmpty(__array) ((OBObjectIsNil(__array)) || (__array.count==0))

//------------------------------ 字体------------------------------------------
/// 设置系统的字体大小（YES：粗体 NO：常规）
#define OBFont(__size__,__bold__) ((__bold__)?([UIFont boldSystemFontOfSize:__size__]):([UIFont systemFontOfSize:__size__]))

//------------------------------颜色------------------------------------------
#pragma mark - 颜色
/// 整个应用的视图的背景色 BackgroundColor
#define OB_MAIN_BACKGROUNDCOLOR [UIColor colorFromHexString:@"#FFFFFF"]
/// 整个应用的分割线颜色
#define OB_MAIN_LINE_COLOR_1 [UIColor colorFromHexString:@"#D9D8D9"]
////  整个应用的主题配置（颜色+字体）MAIN 代表全局都可以修改 使用前须知
#define OB_MAIN_NAVIGATIONBAR_BACKGROUNDCOLOR_2 [UIColor colorFromHexString:@"#37CA8F"]
/// 文字颜色
/// 小标题文字颜色  我的消息 性别 生日等  深灰色 #4A4A4A
#define OB_DarkGray [UIColor colorFromHexString:@"#4A4A4A"]
/// 内容文字  信息结果  中灰色 #9B9B9B
#define OB_MediumGray [UIColor colorFromHexString:@"#9B9B9B"]
/// 内容文字  信息结果  浅灰色 #C5C5C5
#define OB_LightGray [UIColor colorFromHexString:@"#C5C5C5"]

// 颜色
#define OBColor(r, g, b) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:1.0]
// 颜色+透明度
#define OBColorAlpha(r, g, b, a) [UIColor colorWithRed:(r)/255.0 green:(g)/255.0 blue:(b)/255.0 alpha:a]
// 随机色
#define OBRandomColor OBColor(arc4random_uniform(256), arc4random_uniform(256), arc4random_uniform(256))
// 根据rgbValue获取对应的颜色
#define OBColorFromRGB(__rgbValue) [UIColor colorWithRed:((float)((__rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((__rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(__rgbValue & 0xFF))/255.0 alpha:1.0]

#define OBColorFromRGBAlpha(rgbValue, a) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:(a)]
// 设置图片
#define OBImageNamed(__imageName) [UIImage imageNamed:__imageName]

/// 根据hex 获取颜色
#define OBColorFromHexString(__hexString__) ([UIColor colorFromHexString:__hexString__])
/////////-------------朋友圈颜色
/// 全局黑色字体
#define OBGlobalBlackTextColor      [UIColor colorFromHexString:@"#000000"]

/// 全局细下滑线颜色 以及分割线颜色
#define OBGlobalBottomLineColor     [UIColor colorFromHexString:@"#D9D8D9"]

/// 评论or点赞 view的背景色
#define OBMomentCommentViewBackgroundColor [UIColor colorFromHexString:@"#F3F3F5"]
/// 微信昵称字体大小
#define OBMomentScreenNameFont OBFont(16.0f,NO)
/// 微信正文字体大小
#define OBMomentContentFont OBFont(15.0f,NO)
/// 微信地址+时间+来源的字体大小
#define OBMomentCreatedAtFont OBFont(12.0f,NO)
/// 微信（全文/收起）字体大小
#define OBMomentExpandTextFont OBFont(16.0f,NO)

/// 微信评论正文字体大小
#define OBMomentCommentContentFont OBFont(14.0f,NO)
/// 微信评论的昵称的字体大小
#define OBMomentCommentScreenNameFont  OBFont(14.0f,NO)




/// 微信昵称字体颜色
#define OBMomentScreenNameTextColor [UIColor colorFromHexString:@"#5B6A92"]
/// 微信正文（链接、电话）的颜色
#define OBMomentContentUrlTextColor [UIColor colorFromHexString:@"#4380D1"]
/// 微信正文字体颜色
#define OBMomentContentTextColor OBGlobalBlackTextColor
/// 微信时间颜色
#define OBMomentCreatedAtTextColor [UIColor colorFromHexString:@"#737373"]
/// 点击文字高亮的颜色
#define OBMomentTextHighlightBackgroundColor [UIColor colorFromHexString:@"#C7C7C7"]

//------------------------------ 屏幕尺寸相关------------------------------------------
#pragma mark - 屏幕尺寸相关
/// 屏幕尺寸相关
#define OB_SCREEN_WIDTH  ([[UIScreen mainScreen] bounds].size.width)
#define OB_SCREEN_HEIGHT ([[UIScreen mainScreen] bounds].size.height)
#define OB_SCREEN_BOUNDS ([[UIScreen mainScreen] bounds])
#define OB_SCREEN_MAX_LENGTH (MAX(OB_SCREEN_WIDTH, OB_SCREEN_HEIGHT))
#define OB_SCREEN_MIN_LENGTH (MIN(OB_SCREEN_WIDTH, OB_SCREEN_HEIGHT))
/// 导航条高度
#define OB_APPLICATION_TOP_BAR_HEIGHT 64.0f
/// tabBar高度
#define OB_APPLICATION_TAB_BAR_HEIGHT 49.0f
/// 工具条高度 (常见的高度)
#define OB_APPLICATION_TOOL_BAR_HEIGHT 44.0f
/// 状态栏高度
#define OB_APPLICATION_STATUS_BAR_HEIGHT 20.0f
/// 类型相关
#define OB_IS_IPAD (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad)
#define OB_IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone)
/// 手机类型相关
#define OB_IS_IPHONE_4_OR_LESS  (OB_IS_IPHONE && OB_SCREEN_MAX_LENGTH  < 568.0)
#define OB_IS_IPHONE_5          (OB_IS_IPHONE && OB_SCREEN_MAX_LENGTH == 568.0)
#define OB_IS_IPHONE_6          (OB_IS_IPHONE && OB_SCREEN_MAX_LENGTH == 667.0)
#define OB_IS_IPHONE_6P         (OB_IS_IPHONE && OB_SCREEN_MAX_LENGTH == 736.0)
#define OB_IS_IPHONE_X         (OB_IS_IPHONE && OB_SCREEN_MAX_LENGTH == 812.0)
/// 导航条高度
#define OB_APPLICATION_TOP_BAR_HEIGHT (OB_IS_IPHONE_X?88.0f:64.0f)
//------------------------------ ios 系统版本------------------------------------------
#pragma mark - iOS Version
///------
/// iOS Version
///------
#define OBIOSVersion ([[[UIDevice currentDevice] systemVersion] floatValue])

#define OB_iOS7_VERSTION_LATER ([UIDevice currentDevice].systemVersion.floatValue >= 7.0)
#define OB_iOS8_VERSTION_LATER ([UIDevice currentDevice].systemVersion.floatValue >= 8.0)
#define OB_iOS9_VERSTION_LATER ([UIDevice currentDevice].systemVersion.floatValue >= 9.0)
#define OB_iOS10_VERSTION_LATER ([UIDevice currentDevice].systemVersion.floatValue >= 10.0)
#define OB_iOS11_VERSTION_LATER ([UIDevice currentDevice].systemVersion.floatValue >= 11.0)

#define OB_SYSTEM_VERSION_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedSame)
#define OB_SYSTEM_VERSION_GREATER_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedDescending)
#define OB_SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending)
#define OB_SYSTEM_VERSION_LESS_THAN(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] == NSOrderedAscending)
#define OB_SYSTEM_VERSION_LESS_THAN_OR_EQUAL_TO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedDescending)


#endif /* Macros_h */
